<script>
import { mapState } from 'vuex'

export default {
  name: 'cargoForm',
  data() {
    return {
      formData: {
        goodsTypeId: '',
        id: '',
        name: '',
        quantity: '',
        weight: '',
        volume: ''
      }
    }
  },
  methods: {
    getFormData(detail) {
      this.formData.goodsTypeId = detail.goodsType.id
      this.formData.name = detail.name
      this.formData.quantity = detail.quantity
      this.formData.weight = detail.weight
      this.formData.volume = detail.volume
      this.formData.id = detail.id
    }
  },
  computed: {
    ...mapState('cargoStore', ['cargoType'])
  }
}
</script>

<template>
  <el-form label-width="100px">
    <el-form-item label="货品名称">
      <el-input placeholder="请输入货品名称" v-model="formData.name"></el-input>
    </el-form-item>
    <el-form-item label="货品类型">
      <el-select v-model="formData.goodsTypeId">
        <el-option v-for="(item) in cargoType" :value="item.id" :label="item.name" :key="item.id"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="货品数量">
      <el-input placeholder="请输入货品数量" v-model.number="formData.quantity"></el-input>
    </el-form-item>
    <el-form-item label="货品重量">
      <el-input placeholder="请输入货品重量" v-model.number="formData.weight"></el-input>
    </el-form-item>
    <el-form-item label="货品体积">
      <el-input placeholder="请输入货品体积" v-model.number="formData.volume"></el-input>
    </el-form-item>
  </el-form>
</template>

<style scoped lang="scss">
.el-form {
  width: 80%;

  .el-select {
    width: 100%;
  }
}
</style>
